
package com.probiz.estoresf.customer.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.probiz.estore.common.model.sales.Coupon;
import com.probiz.estore.common.model.sales.GiftCertificate;
import com.probiz.estore.common.service.GiftCertificateService;
import com.probiz.estore.common.service.PromoService;
import com.probiz.estore.core.controller.GenericStoreFrontController;
import com.probiz.estore.webapp.util.RequestUtil;

/**
 * 前台礼券优惠券查询controller
 * @author ProBIZ
 *
 */
public class GiftCouponFrontController extends GenericStoreFrontController<Object> {

    private PromoService promoService = null;
    
    private GiftCertificateService giftCertificateService  = null;
    
    
    public PromoService getPromoService() {
		return promoService;
	}


	public void setPromoService(PromoService promoService) {
		this.promoService = promoService;
	}


	public GiftCertificateService getGiftCertificateService() {
		return giftCertificateService;
	}


	public void setGiftCertificateService(GiftCertificateService giftCertificateService) {
		this.giftCertificateService = giftCertificateService;
	}
	
	@Override
	protected void initController() throws Exception {
	}


	public ModelAndView defaultAction(HttpServletRequest request,
            HttpServletResponse response) {

        return new ModelAndView("sales/giftCouponQuery");
    }
    
  
    public ModelAndView queryGiftCouponAction(HttpServletRequest request,
            HttpServletResponse response){
        String giftCouponNo=RequestUtil.getParameterNullSafe(request, "giftCouponNo").trim();
          
        Coupon coupon = promoService.queryCouponByNo(giftCouponNo);
		request.setAttribute("coupon",coupon);
        GiftCertificate giftCertificate = giftCertificateService.queryGiftCertificateByNo(giftCouponNo);
		request.setAttribute("giftCertificate",giftCertificate);
        request.setAttribute("giftCouponNo",giftCouponNo);
        
        return new ModelAndView("sales/giftCouponQuery");
        
    }


	
}
